package com.dify.tool.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dify.tool.api.common.PageResult;
import com.dify.tool.api.dto.TestDTO;
import com.dify.tool.api.vo.TestVO;
import com.dify.tool.common.utils.PageUtil;
import com.dify.tool.dal.entity.Test;
import com.dify.tool.dal.mapper.TestMapper;
import com.dify.tool.service.ITestService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;


/**
 * <p>
 * 代码生成业务表 服务实现类
 * </p>
 *
 * @author shl
 * @since 2024-06-24
 */
@Service
public class TestServiceImpl extends ServiceImpl<TestMapper, Test> implements ITestService {

    @Resource
    private TestMapper testMapper;

    @Override
    public TestVO test() {
        Test test = testMapper.selectById(1910606810512314369L);
        TestVO testVO = BeanUtil.copyProperties(test, TestVO.class);
        return testVO;
    }

    @Override
    public void add(TestDTO testDTO) {
        Test test = BeanUtil.copyProperties(testDTO, Test.class);
        testMapper.insert(test);
    }

    @Override
    public PageResult<TestVO> testPage(TestDTO testDTO) {
        IPage<Test> page = new Page<>(testDTO.getPage(), testDTO.getPageSize());
        IPage<Test> page1 = this.page(page);
        return PageUtil.convert(TestVO.class, page1);
    }

}
